recompute: display one of the changed files
authorJoey Hess <joeyh@joeyh.name>
Mon, 3 Mar 2025 19:12:19 +0000 (15:12 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 3 Mar 2025 19:12:19 +0000 (15:12 -0400)
Command/Recompute.hs
doc/git-annex-recompute.mdwn

index 81fe35cbff9b888d2e218516c138371214816f03..2eda09886771c202bdbb6aa699a0bfa2963d2cc9 100644 (file)
@@ -79,18 +79,22 @@ start' o r si file key =
        Remote.Compute.getComputeState
                (Remote.remoteStateHandle r) key >>= \case
                        Nothing -> stop
-                       Just state ->
-                               stopUnless (shouldrecompute state) $
-                                       starting "recompute" ai si $
-                                               perform o r file key state
+                       Just state -> shouldrecompute state >>= \case
+                               Nothing -> stop
+                               Just mreason -> starting "recompute" ai si $ do
+                                       maybe noop showNote mreason
+                                       perform o r file key state
   where
        ai = mkActionItem (key, file)
 
        shouldrecompute state
-               | originalOption o = return True
-               | otherwise = 
-                       anyM (inputchanged state) $
-                               M.toList (Remote.Compute.computeInputs state)
+               | originalOption o = return (Just Nothing)
+               | otherwise = firstM (inputchanged state)
+                       (M.toList (Remote.Compute.computeInputs state))
+                       >>= return . \case
+                               Nothing -> Nothing
+                               Just (inputfile, _) -> Just $ Just $
+                                       QuotedPath inputfile <> " changed"
 
        inputchanged state (inputfile, inputkey) = do
                -- Note that the paths from the remote state are not to be
@@ -109,11 +113,13 @@ start' o r si file key =
                                        Just (sha, _, _) -> sha /= inputgitsha
                                        Nothing -> inputfilemissing
                                Nothing -> return inputfilemissing
-       
-       -- When an input file is missing, go ahead and recompute. This way,
-       -- the user will see the computation fail, with an error message that
-       -- explains the problem.
-       inputfilemissing = True
+         where
+               -- When an input file is missing, go ahead and recompute.
+               -- This way, the user will see the computation fail,
+               -- with an error message that explains the problem.
+               -- Or, if the input file is only optionally used by the
+               -- computation, it might succeed.
+               inputfilemissing = True
 
 perform :: RecomputeOptions -> Remote -> OsPath -> Key -> Remote.Compute.ComputeState -> CommandPerform
 perform o r file origkey origstate = do
index fb895aa75c78da64893dd1f38626485b834fe9d5..0f8dd56901f7c13a34c287bceb656905f128af6e 100644 (file)
@@ -15,7 +15,8 @@ By default, this only recomputes files whose input files have changed.
 The new contents of the input files are used to re-run the computation.
 
 When the output of the computation is different, the computed file is
-updated with the new content.
+updated with the new content. The updated file is written to the worktree,
+but is not staged, in order to avoid overwriting any staged changes.
 
 # OPTIONS